<?php
/** 
 * Created by RisingSun. 
 * User: MarkSpace 
 * Date: 20210822
 * Time: 11:05 
 */
namespace app\content\controller;

use  Mscore\Core\Controller;
use  app\admin\model\Login as LoginModel;

class AuthController extends Controller{

    public $login;
  
    public function __construct()  
    {    
        $this->login = (new LoginModel)->isAuth();
        if(isset($this->login['code'])&&$this->login['code']==401){
            echo json_encode($this->login);
            Header("Location:".config('server.login_url'));
            exit;
        }
    }   
    /**
     * 返回权限给前端
     * @param array $index 
     * @param array $where 
    */
    public function role(){
        $data=["code" => 200, "data" =>'', "msg" => 'true'];
        foreach ($this->login['checkrole'] as $key => $value) {
            if($value['id']==post('id')||$value['url']==post('id')){
                $data["data"]=$value;
                continue;
            }
        }
        return $this->echojson($data);
    }
}